//https://blog.csdn.net/mjzhang1993/article/details/78626316


const childprocess = require('child_process');
var args=[ '{"framework":"/Users/star/work/node_server/egg-example/egg-master","baseDir":"/Users/star/work/node_server/egg-example","port":7001,"workers":2,"plugins":null,"https":false,"clusterPort":51161}' ]

//child_process.fork(modulePath[, args][, options])
const agentWorker = childprocess.fork('./agent.js', args, {});

agentWorker.on('message',d=>{
	console.log(d);
	agentWorker.send(d);
})
agentWorker.on('error',e=>{
	console.log(e)
})
//当kill 时exit close 都会执行
agentWorker.on('exit',(code, signal)=>{
	console.log(code,signal);
})
agentWorker.on('close', function (code) {
      console.log('子进程已退出，退出码 ' + code);
});


